/*************************************************************************
	> File Name: Server.h
	> Author: gyl
	> Mail: gyldeyx@qq.com
	> Created Time: Thu 11 Feb 2021 01:19:02 AM CST
 ************************************************************************/

#ifndef __SERVER_H_
#define __SERVER_H_

#define MAX_FD 65536
#define MAX_EVENT_NUMBER 1024
#define TIMESLOT 5

#include <sys/epoll.h>
#include "threadpool.h"
#include "listtimer.h"

class Http;
class Server {
public:
    Server(); 
    ~Server(); 

    void init(int iPort = -1, int iThreadNumber = -1);
    void start();

private:
    void adjust_timer(util_timer *timer);
    void deal_timer(util_timer *timer, int sockfd);
    void timer_handler();

private:
    int m_iPort;            //监听端口
    int m_iThreadNumber;    //线程数

    int m_iIsInit;          //server是否初始化，0未初始化，1初始化

    int m_iListenFd;        //监听socket
    int m_iEpollFd;         //epollfd

    Http *m_pHttpUsers;            //管理所有用户
    threadpool<Http> *m_pThreadPool = NULL;

    //维护一个
    client_data *users_timer;

    sort_timer_lst m_timer_lst;
};



#endif
